import dataList from '@/components/dataList'
import {configureQuery} from "@/views/property-info-sys/building-manage/api/building.js";
let moment = require('moment')
export default {
    name: "property_list",
    components: {dataList},
    provide() {
        return {
            initList: this.getListData,
        };
    },
    beforeMount() {
        this.getListData();
    },
    data()  {
        return {
            current: '20',
            // 表单绑定
            tableData: [],
            // 请求参数
            params: {
                current: 1,
                size: 10,
                buildingName: ''
            },
            // 分页
            pager: {
                total: 0, // 总页数
                current: 1, // 当前页数
                size: 10 // 每页显示多少条
            },
            // 页面loading
            loading: false,
            filterList: [
                { label: '建设单位', inputType: 'input', name: 'constructionUnit'},
                { label: '项目名称', inputType: 'input', name: 'projectName'},
                { label: '竣工时间', inputType: 'daterange', name: ['completeTimeStart','completeTimeEnd']},
                { label: '是否VR', inputType: 'select', name: 'isVr', multiple: true,children: [
                        {
                            label:'是',
                            value:'1',
                        },
                        {
                            label:'否',
                            value:'0',
                        }
                    ]}
            ]
        }
    },
    methods: {
        //分页请求
        getListData(params = {}){
            this.loading = true
            let requestData = {...this.params, ...params}
            configureQuery(requestData).then(res => {
                const  {current, size, total, records} = res.data.data
                this.tableData = records
                this.params = requestData
                this.pager = {total, current, size}
            }).finally(() => {
                this.loading = false
            })
        },
        //查看
        toLook(row) {
            this.$router.push({name: 'building_look', query: { 'id' : row.buildingId, 'projectId': row.projectId, 'current': this.current } })
        },
        //修改
        toEdit(row) {
            this.$router.push({name: 'building_edit', query: { 'id' : row.buildingId, 'projectId': row.projectId, 'current': this.current } })
        },
        //时间格式过滤
        dateFormat: function(row, column, cellValue){
            if(!cellValue){
                return ''
            }
            return moment(cellValue).format('YYYY-MM-DD')
        },
    }
}
